#pragma once

#include "cocos2d.h"
#include <list>
#include "scripttemplate.h"
#include "character.h"
#include "pathengine.h"

USING_NS_CC;
using namespace std;


class CPC;

class CWorld
{
public:
	void Init();
	void Create(CCLayer* layer);
	void CreateObject();
	void InsertScriptObject(CScriptTemplate* script);

	void GetPos(string& genpos, CCPoint& genpoint);
	bool IsValidPoint(CCPoint& point);
	void findPath(CCPoint& startPos, CCPoint& goalPos, list<CCPoint> &pathlist);

	void GetAroundCharacter(ICharacter* character, map<float,ICharacter*>& charlist, float ai_see_range);

	void Update(ccTime dt);

public:
	CCLayer* _layer;
	CCTMXTiledMap* _map;
	CCTMXLayer* _metaset;

private:
	map<UINT, CScriptTemplate*> _scriptlist;
	map<UINT, CNPC*> _dienpc_list;
	map<UINT, ICharacter*> _characterlist;

	CPathEngine _pathengine;
};